<html>
<head>
   <title>HSTP-<?php $this->_block('title'); ?><?php $this->_endblock(); ?></title>
    <link rel="stylesheet" type="text/css" href="<?php echo $_BASE_DIR; ?>resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo $_BASE_DIR; ?>css/hstp.css" />
   
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
	<script src="<?php echo $_BASE_DIR; ?>js/jquery.form.js" type="text/javascript"></script>
	<script src="<?php echo $_BASE_DIR; ?>js/jquery.datepick.min.js" type="text/javascript" ></script>
	<script src="<?php echo $_BASE_DIR; ?>js/jquery.covertape-0.3.js" type="text/javascript"></script>
    <!-- GC -->
    <!-- LIBS -->
    <script type="text/javascript" src="<?php echo $_BASE_DIR; ?>adapter/ext/ext-base.js"></script>
	
    <!-- ENDLIBS -->

    <script type="text/javascript" src="<?php echo $_BASE_DIR; ?>ext-all.js"></script>

    <!-- EXAMPLES -->
    <script type="text/javascript" src="<?php echo $_BASE_DIR; ?>shared/examples.js"></script>
  
    <script type="text/javascript">
    $(document).ready(function() {
		
	});

	var action1 = new Ext.Action({
    icon: 'images/counts.png',
	text: '查看所有主机',
    handler: function(){
        Ext.Msg.alert('Click','You clicked on "Action 1".');
    }
});

var action1A = new Ext.Action({
    icon: 'images/counts.png',
	text: '未分组主机',
    handler: function(){
        Ext.Msg.alert('Click','You clicked on "Action 1".');
    }
});

var action1B = new Ext.Action({
    icon: 'images/counts.png',
	text: '添加主机组',
    handler: function(){
        Ext.Msg.alert('Click','You clicked on "Action 1".');
    }
});

var action1C = new Ext.Action({
    icon: 'images/counts.png',
	text: '添加组管理员',
    handler: function(){
        Ext.Msg.alert('Click','You clicked on "Action 1".');
    }
});

var action2 = new Ext.Action({
    text: 'Action 2',
    handler: function(){
        Ext.Ajax.request({
		   url: '11.html',
		   success: function(response, opts) {
			  
			  //var obj = Ext.decode(response.responseText);
			  //alert(obj);
			  //Ext.Msg.alert(obj);
			  mainTabPanel.update(response.responseText);
			  //console.dir(obj);
		   },
		   failure: function(response, opts) {
			  console.log('server-side failure with status code ' + response.status);
		   }
		});
		//Ext.Msg.alert('Click','You clicked on "Action 2".');
    }
});
var action3 = new Ext.Action({
    text: 'Action 3',
    handler: function(){
        Ext.Msg.alert('Click','You clicked on "Action 3".');
    }
});
var action4 = new Ext.Action({
    text: 'Action 4',
    handler: function(){
        Ext.Msg.alert('Click','You clicked on "Action 4".');
    }
});

var action4A = new Ext.Action({
    icon: 'images/counts.png',
	text: '权限管理',
    handler: function(){
	//4A-S
	mainTabPanel.update('<div id="paging-grid1"></div>');
	//DATA
	var storeiu = new Ext.data.JsonStore({	
			totalProperty: 'total',	// total data, see json output
			root: 'root',	// see json output	
			url: 'index.php?namespace=admin&controller=users&action=indexpart1', 			
			fields: [
				{name: 'date'},
			   {name: 'pageview', type: 'string'},
			   {name: 'ip', type: 'string'},
			   {name: 'op', type: 'string'}
			]
		});

			// load data from the url ( data.php ) and add start and limit parameter
	storeiu.load({params:{start: 0, limit: 8}});
	var gridho=$('#paging-grid1').parent().height();
    // create the Grid
    var gridiu = new Ext.grid.GridPanel({
        store: storeiu,
        columns: [
            new Ext.grid.RowNumberer(),
    				    {header:"日期",sortable:false,resizable:true,dataIndex:"date",menuDisabled:true,align: "center"
    					},
    					{header:"Page View",sortable:false,resizable:true,menuDisabled:true,dataIndex:"pageview"
    					},
    					{header:"IP",sortable:false,resizable:true,menuDisabled:true,dataIndex:"ip"
    					},
						{header:"操作",sortable:false,resizable:true,menuDisabled:true,dataIndex:"op"
    					}
        ],
        stripeRows: true,
        title:'Paging Grid',
		header:false,
		height:gridho,
		bbar: new Ext.PagingToolbar({
			pageSize: 8,	// data to display
			store: storeiu,
			displayInfo: true,
			displayMsg: 'Displaying topics {0} - {1} of {2}',
			emptyMsg: "No topics to display"			
		})
    });

	// render this grid to paging-grid element
    gridiu.render('paging-grid1');
	//DATA END

	Ext.Ajax.request({
		   url: 'index.php?namespace=admin&controller=users&action=add',
		   success: function(response, opts) {
			  
			  leftTabPanel.update(response.responseText);

			  $('#form_memberadd').ajaxForm({
					
					success: function() {
						Ext.example.msg('Button Click', 'You clicked the {0} button', '成功');
						//alert('成功!');
					}
			  });
		   },
		   failure: function(response, opts) {
			  console.log('server-side failure with status code ' + response.status);
		   }
		});

	//4A-E
	}
});

var action5A = new Ext.Action({
    icon: 'images/counts.png',
	text: '操作日志',
    handler: function(){
        //DATA START
		mainTabPanel.update('<div id="paging-grid2"></div>');
		var st=$("input[name=startdate]").val();
		var et=$("input[name=enddate]").val();
		var storeiu1 = new Ext.data.JsonStore({	
			totalProperty: 'total',	// total data, see json output
			root: 'root',	// see json output	
			url: 'index.php?controller=operatereport&action=indexo',
			baseParams: {startdate:'',enddate:''},
			fields: [
				{name: 'date'},
			   {name: 'pageview', type: 'string'},
			   {name: 'ip', type: 'string'},{name: 'pvuv', type: 'string'},
			   {name: 'op', type: 'string'}
			]
		});	    

		storeiu1.load({params:{start: 0, limit: 14}});
		var gridho1=$('#paging-grid2').parent().height();
    
		var gridiu1 = new Ext.grid.GridPanel({
        store: storeiu1,
        columns: [
            new Ext.grid.RowNumberer(),
    				    {header:"ID",sortable:false,resizable:true,dataIndex:"date",menuDisabled:true,align: "center"
    					},
    					{header:"用户",sortable:false,resizable:true,menuDisabled:true,dataIndex:"pageview"
    					},
    					{header:"IP地址",sortable:false,resizable:true,menuDisabled:true,dataIndex:"ip"
    					},
						{header:"操作",sortable:false,resizable:true,menuDisabled:true,dataIndex:"pvuv"
    					},
						{header:"日期",sortable:false,resizable:true,menuDisabled:true,dataIndex:"op"
    					}
        ],
        stripeRows: true,
        title:'Paging Grid',
		header:false,
		height:gridho1,
		bbar: new Ext.PagingToolbar({
			pageSize: 14,	// data to display
			store: storeiu1,
			displayInfo: true,
			displayMsg: 'Displaying topics {0} - {1} of {2}',
			emptyMsg: "No topics to display",
			paramNames: {start: 'start', limit: 'limit'}
		})
		});

		gridiu1.render('paging-grid2');
		//DATA END

		Ext.Ajax.request({
		   url: 'index.php?controller=operatereport&action=output',
		   success: function(response, opts) {
			  
			  leftTabPanel.update(response.responseText);
			  //$("#xia").html('qweqweqwe');
			  $("#xia").datecontrol({format:"Y-m-d"});
			  $("input[name=btn_submit]").click(function(){
					var st=$("input[name=startdate]").val();
					var et=$("input[name=enddate]").val();
					storeiu1.load({params:{start: 0, limit: 14,startdate: st,enddate: et}});
					storeiu1.baseParams['startdate']=st;
					storeiu1.baseParams['enddate']=et;
					//Ext.example.msg('Button Click', 'You clicked the {0} button', '成功');
			  });

			  $("input[name=btn_output]").click(function(){

				  Ext.Ajax.request({
					   url: 'index.php?controller=operatereport',
					   success: function(response, opts) {
						window.open('output.xls');
					   },
					   params: { startdate: jQuery("input[name=startdate]").val(),
						  enddate: jQuery("input[name=startdate]").val(),
						   excel: '1'}
				 });		
			  });

			  $("input[name=btn_delete]").click(function(){
					if(jQuery("input[name=startdate]").val() && jQuery("input[name=enddate]").val()){
	
						if(confirm("确认删除吗？")){
							  Ext.Ajax.request({
								   url: 'index.php?controller=operatereport&action=delete',
								   success: function(response, opts) {
									Ext.example.msg('Button Click', 'You clicked the {0} button', '成功');
									var st=$("input[name=startdate]").val();
									var et=$("input[name=enddate]").val();
									storeiu1.load({params:{start: 0, limit: 14,startdate: st,enddate: et}});

									//window.open('output.xls');
								   },
								   params: { startdate: jQuery("input[name=startdate]").val(),
									  enddate: jQuery("input[name=startdate]").val()}
							 });
						}
					}
			  });

		   },
		   failure: function(response, opts) {
			  console.log('server-side failure with status code ' + response.status);
		   }
		});
    }
});

var action7A = new Ext.Action({
    icon: 'images/counts.png',
	text: '服务器配置',
    handler: function(){
        //leftTabPanel.collapse(false);

		leftTabPanel.load({
			url: "index.php?action=userwel"
		});

//		mainTabPanel.load({
//			url: "index.php?action=mailsetting"
//		});
		//http://localhost/hsmp/public/index.php?action=mailsetting
		//alert(leftTabPanel.collapsible);
		//Ext.Msg.alert('Click','You clicked on "Action 1".');
    }
});

var leftTabPanel =new Ext.Panel({
	region: 'west',
        border:true,
        title: '快速启动',
        margins: '5 0 0 0', 
        cmargins: '5 5 0 0',
        bodyStyle:{
			padding: '5px 5px 5px 5px'
		},
		cls: 'mailb leftt x-panel',
        autoScroll:true,
        labelWidth:100,
        collapsible:true,
        split:true,
        width:150,
        minSize: 150,
        maxSize: 200,
		//html: '<ul><li class="doc" id="qone"><span><a>最新报警记录</a></span></li><li class="doc" id="qtwo"><span><a>状态日志</a></span></li><li class="doc" id="qthree"><span><a>主机连接信息</a></span></li><li class="doc" id="qlicense"><span><a>授权信息</a></span></li><li class="doc" id="qmailsetting"><span><a>报警邮箱设置</a></span></li><li class="doc" id="qremailing"><span><a>接收邮箱设置</a></span></li></ul>'
        items:[
//           new Ext.form.TextField({fieldLabel: 'First Name',name: 'first',width:130}),
//           new Ext.form.TextField({fieldLabel: 'Last Name',name: 'last',width:130}),
		  new Ext.Button({
        text: '最新日志',
        handler: function()  
        {
			Ext.Msg.alert('Click','You clicked on "Action 1".');
        }  
    })
        ]
});

var mainTBar = new Ext.Toolbar({
items:[{                   
        icon: 'images/acts.png',
		text: '在线主机',
        menu: [action1,action1A,action1B,action1C]          
    },
    {                   
        icon: 'images/counts.png',
		text: '控制向导',
        menu: [action2,action3,action4]          
    },
    {                   
        icon: 'images/counts.png',
		text: '任务查看',
        menu: [action2,action3,action4]          
    },action4A,action5A,{                   
        icon: 'images/counts.png',
		text: '实时监控',
        menu: [action2,action3,action4]          
    },action7A]
}) 


var mainTabPanel = new Ext.Panel({
                region: 'center',
				title: '行为日志报警',
				margins: '5 0 0 0',
				cls: 'mailb x-panel',
				autoScroll:true,
				bodyStyle: {
					background: '#ffffff',
					padding: '0px'
				},
				html: '<div id="paging-grid"></div>'
            });
			
	Ext.onReady(function(){
    
        
		
		
		// NOTE: This is an example showing simple state management. During development,
        // it is generally best to disable state management as dynamically-generated ids
        // can change across page loads, leading to unpredictable results.  The developer
        // should ensure that stable state ids are set for stateful components in real apps.
        Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
        
        var viewport = new Ext.Viewport({
            layout: 'border',
            items: [
            // create instance immediately
            new Ext.Panel({
                region: 'north',
				title : '<img style="height:90px;" src="<?php echo $_BASE_DIR; ?>images/logo.png" />',
				tbar: mainTBar,
				cls: 'titlelogo x-panel',
				headerAsText:true,
				bodyStyle: {
					display: 'none'
				}
            }), {
                // lazily created panel (xtype:'panel' is default)
                region: 'south',
                height: 25, // give north and south regions a height
				overClass:'x-view-over',
				bodyStyle: {
					background: '#DFE8F6',
					border: 'none'
				},
                html: '<p>&copy; 2010 clickpro.cn</p>'
            },leftTabPanel,mainTabPanel]
        });
        // get a reference to the HTML element with id "hideit" and add a click listener to it 
        
		/*style fixed*/
		//$('#ext-gen11').hide();
		$('.titlelogo .x-panel-header').css({'background-image': "none"});
		//$('.mailb').hide();
		$('.mailb').css({'top': "133px"});
		//$('#ext-comp-1016').css({'top': "133px"});

		//DATA
		// create the data store
		var store = new Ext.data.JsonStore({	
			totalProperty: 'total',	// total data, see json output
			root: 'root',	// see json output	
			url: 'index.php?action=toplog', 			
			fields: [
				{name: 'date'},
			   {name: 'pageview', type: 'string'},
			   {name: 'ip', type: 'string'},
			   {name: 'visits', type: 'string'},
			   {name: 'uv', type: 'string'},
			   {name: 'pvuv', type: 'string'},
			   {name: 'op', type: 'string'}
			]
		});	    

	// load data from the url ( data.php ) and add start and limit parameter
	store.load({params:{start: 0, limit: 8}});
	var gridh=$('#paging-grid').parent().height();
    // create the Grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            new Ext.grid.RowNumberer(),
    				    {header:"日期",sortable:false,resizable:true,dataIndex:"date",menuDisabled:true,align: "center"
    					},
    					{header:"Page View",sortable:false,resizable:true,menuDisabled:true,dataIndex:"pageview"
    					},
    					{header:"IP",sortable:false,resizable:true,menuDisabled:true,dataIndex:"ip"
    					},
    					{header:"Visits",sortable:false,resizable:true,menuDisabled:true,dataIndex:"visits"
    					},
    					{header:"UV",sortable:false,resizable:true,menuDisabled:true,dataIndex:"uv"
    					},
						{header:"PV/UV",sortable:false,resizable:true,menuDisabled:true,dataIndex:"pvuv"
    					},
						{header:"操作",sortable:false,resizable:true,menuDisabled:true,dataIndex:"op"
    					}
        ],
        stripeRows: true,
        title:'Paging Grid',
		header:false,
		height:gridh,
		bbar: new Ext.PagingToolbar({
			pageSize: 8,	// data to display
			store: store,
			displayInfo: true,
			displayMsg: 'Displaying topics {0} - {1} of {2}',
			emptyMsg: "No topics to display"			
		})
    });

	// render this grid to paging-grid element
    grid.render('paging-grid');

	//$('#paging-grid').css({'height': "180px"});
		//DATA END
    });
    </script>
</head>
<body>
    
</body>
</html>